﻿namespace Moe.ECamel.Common.Entities
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;

	partial class SubscriptionItemTypeInfo
	{
		public string ItemTypeName
		{
			get { return this.ItemType.ItemTypeName; }
		}
		public float Price
		{
			get { return this.Quantity * this.ItemTypeInfo.PricePerUnit; }
		}
		public float Deposit
		{
			get { return this.Quantity * this.ItemTypeInfo.DepositFeePerUnit; }
		}

		public int MaxRentalDays
		{
			get { return this.ItemTypeInfo.MaxRentalDays; }
		}
		public float FinePerExtraRentalDay
		{
			get { return this.ItemTypeInfo.FinePerExtraRentalDay; }
		}

		private SubscriptionTypeItemTypeInfo _itemTypeInfo;
		private SubscriptionTypeItemTypeInfo ItemTypeInfo
		{
			get
			{
				if (_itemTypeInfo == null)
					_itemTypeInfo = this.Subscription.SubscriptionType.SubscriptionTypeItemTypeInfos.Single(a => a.ItemTypeId == this.ItemTypeId);
				return _itemTypeInfo;
			}
		}
	}
}